# ending:utf-8
"""
@Time:2025/6/7 15:14
@Author:luyinglin
@Email:2902801287@qq.com
@File:model.py
"""
from python.extensions import db  # 确保导入正确的 db 实例
from python.extensions import db


class Attraction(db.Model):
    __tablename__ = 'attractions'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    city = db.Column(db.String(50), nullable=False)
    province = db.Column(db.String(50), nullable=False)
    star_level = db.Column(db.String(10))  # 如"4A"、"5A"
    rating = db.Column(db.Float)
    price = db.Column(db.Float)
    sales = db.Column(db.Integer)

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'city': self.city,
            'province': self.province,
            'star_level': self.star_level,
            'rating': self.rating,
            'price': self.price,
            'sales': self.sales
        }